<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>数组filter方法</title>
    </head>
    <body>
        <h1>数组filter方法</h1>
        <ol>
            <li>var arr=[16,20,30,40,18,22];</li>
            <li>var filterArr=arr.filter(greater22);</li>
            <li>function greater22(currentValue){</li>
            <li>return currentValue>22;</li>
            <li>}</li>
            <li>console.log('filterArr',filterArr);// [30,40]</li>
        </ol>
        <script>
            var arr=[16,20,30,40,18,22];
            var filterArr=arr.filter(greater22);
            function greater22(currentValue){
                return currentValue>22;
            }
            console.log('filterArr',filterArr);
        </script>
    </body>
</html>